/** * @license * Copyright (c) 2014, 2018, Oracle and/or its affiliates. * The Universal Permissive License (UPL), Version 1.0 */ "use strict";define(["ojs/ojcore","jquery","knockout","jqueryui-amd/widget","ojs/ojkoshared","ojs/ojkeyset"],function(e,t,n){function r(){this.Init()}function i(e,t){var n={};return n.value=t.value,n}var o,a,s;function u(e,t,n){return"pieCenter"===e&&t.template&&(t._renderer=m(n,t.template)),{pieCenter:t}}function l(e,t,r){return"optionTemplate"===e&&null!==t?{optionRenderer:function(e,t){return function(r){var i,o;return i=r.parentElement,o=e.createChildContext(r.data,null,function(e){e.$optionContext=r}),n.renderTemplate(t,o,null,i),null}}(r,String(t))}:null}function d(e,t){this.Init(e,t)}function c(e,t){var n={};return function(r){var i,o;return i=r.parentElement,o=e.createChildContext(r.data,null,function(e){e.$key=r.key,e.$metadata=r.metadata,e.$headerContext=r}),f(r,t,i,o,n),null}}function p(e,t){var n={};return function(r){var i,o;return i=r.parentElement,o=e.createChildContext(r.data,null,function(e){e.$keys=r.keys,e.$metadata=r.metadata,e.$cellContext=r,e.$cell=r.cell}),f(r,t,i,o,n),null}}function f(e,r,i,o,a){var s,u;for(s=function(e,t){var r=t[e];null==r&&(r=n.utils.parseHtmlFragment(document.getElementById(e).innerHTML),t[e]=r);return r.map(function(e){return e.cloneNode(!0)})}(function(e,t){if("function"==typeof e)return e(t);return e}(r,e),a),n.virtualElements.setDomNodeChildren(i,s),n.applyBindingsToDescendants(o,i),u=0;u0;){var r=this._queue.shift();r.tracker.applyChanges(r.changes)}},e.ComponentBinding=function(e,t){this.Init(e,t)},e.Object.createSubclass(e.ComponentBinding,e.Object,"oj.ComponentBinding"),e.ComponentBinding.create=function(t,r){if(null==t)throw"Binding name is required!";var i,o=new e.ComponentBinding(t,r),a=(o._getBindingOptions().componentName,n.bindingHandlers),s=Array.isArray(t)?t:[t];for(i=0;i=0;i--){var s=r[i];if(null!=s.attributes&&o.push(s),n){var u=s.use;if(null!=u){u=Array.isArray(u)?u:[u];for(var l=0;l0)for(var l=0;l=0){i[d]={init:p.init,update:p.update,afterCreate:p.afterCreate,beforeDestroy:p.beforeDestroy};break}}return i},e.ComponentBinding._HANDLER_NAMESPACE=".oj_ko",e.ComponentBinding._registerWritebacks=function(t,n){for(var r={"^slider$":[{event:"slidechange",getter:i}],"^oj*":[{event:"ojoptionchange",getter:function(e,t,n){var r={},i=n.optionMetadata;if(i&&"shouldWrite"===i.writeback){var o=n.option;r[o]=n.value,i.readOnly&&(e.readOnlyProperties[o]=!0)}return r}.bind(void 0,n)}]},o={},a=Object.keys(r),s=0;s=0){var c=s[e.ComponentBinding._OPTION_MAP],p=null==c?null:c[d],f=s[d];e.ComponentBinding._writeValueToProperty(d,f,a[d],p,n.bindingContext,o)}}finally{n.changeTracker.resume(d)}}})}break}}},e.ComponentBinding._writeValueToProperty=function(t,r,i,o,a,s){if(null!=r&&n.isObservable(r))n.isWriteableObservable(r)&&r(e.ComponentBinding.__cloneIfArray(i));else{if(!(t in s)){var u=null,l=e.__ExpressionUtils.getPropertyWriterExpression(o);null!=l&&(u=e.ComponentBinding.__CreateEvaluator(l)),s[t]=u}var d=s[t];if(d)d(a)(e.ComponentBinding.__cloneIfArray(i))}},e.ComponentBinding._toJS=function(t){return t=n.utils.unwrapObservable(t),(Array.isArray(t)||e.CollectionUtils.isPlainObject(t))&&t.ojConvertToJS&&(t=n.toJS(t)),t},e.ComponentBinding.__cloneIfArray=function(e){return Array.isArray(e)&&(e=e.slice()),e},e.ComponentBinding.__removeDotNotationOptions=function(e){for(var t={},n=Object.keys(e),r=0;r=0&&(t[i]=e[i],delete e[i])}return t},e.ComponentBinding._deliverCreateDestroyEventToManagedProps=function(e,t,n,r,i,o,a){for(var s=Object.keys(t),u=0;u=0},e.ComponentBinding._REGISTERED_NAMES=[],e.ComponentBinding._COMPONENT_OPTION="component",e.ComponentBinding._OPTION_MAP="_ojOptions",o="cleanExternalData",a=n.utils.domNodeDisposal,s=a[o],a[o]=function(t){var n=e.DomUtils?e.DomUtils.setInKoCleanExternal:null;n&&n(t);try{s(t)}finally{n&&n(null)}},e.ComponentBinding._INSTANCE=e.ComponentBinding.create(["ojComponent","jqueryUI"]),t.widget("oj._ojDetectCleanData",{options:{cleanParent:!1},_destroy:function(){var e,t;t=(e=n.utils.domNodeDisposal).cleanExternalData,e.cleanExternalData=function(){};try{this.options.cleanParent&&null!=this.element[0].parentNode?n.cleanNode(this.element[0].parentNode):n.cleanNode(this.element[0])}finally{e.cleanExternalData=t}}}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({attributes:["pieCenter"],init:function(e,t,n,r,i,o,a){return u(e,t,a)},update:function(e,t,n,r,i,o,a){return u(e,t,a)},for:"ojChart"}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({attributes:["optionTemplate"],init:function(e,t,n,r,i,o,a){var s=l(e,t,a);if(null!==s)return s},update:function(e,t,n,r,i,o,a){return l(e,t,a)},for:"ComboboxOptionRenderer"}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({for:"ojCombobox",use:"ComboboxOptionRenderer"}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({for:"ojSelect",use:"ComboboxOptionRenderer"}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({for:"ojInputSearch",use:"ComboboxOptionRenderer"}),e.Object.createSubclass(d,e.Object,"ComponentBinding.ComponentChangeTracker"),d.prototype.Init=function(e,t){d.superclass.Init.call(this),this._updateCallback=e,this._queue=t,this._changes={},this._suspendCountMap={}},d.prototype.addChange=function(e,t){this._isSuspended(e)||this._disposed||(this._changes[e]=t,this._queue.registerComponentChanges(this))},d.prototype.dispose=function(){this._disposed=!0},d.prototype.resume=function(t){var n=this._suspendCountMap[t]||0;--n<0?e.Logger.error("ComponentChangeTracker suspendCount underflow"):0==n?delete this._suspendCountMap[t]:this._suspendCountMap[t]=n},d.prototype.suspend=function(e){var t=this._suspendCountMap[e]||0;this._suspendCountMap[e]=t+1},d.prototype.applyChanges=function(e){this._disposed||this._updateCallback(e)},d.prototype.flushChanges=function(){var e=this._changes;return this._changes={},e},d.prototype._isSuspended=function(e){return(this._suspendCountMap[e]||0)>=1},n.bindingHandlers.ojContextMenu={update:function(r,i,o,a,s){var u,l,d=t(r),c=!1,p=!1,f=null,h=function(e){if(c)return e.preventDefault(),e.stopPropagation(),c=!1,!1},g=function(e){121==e.which&&e.shiftKey&&v().is(":visible")&&e.preventDefault()},m=function(){var t=e.Components.__GetWidgetConstructor(v()[0],"ojMenu"),n=t&&t("instance");if(!n)throw new Error('ojContextMenu binding bound to "'+(x||E)+'", which does not reference a valid JET Menu.');return b||(n.widget().on("ojclose.ojContextMenu",function(e,t){document.removeEventListener("keyup",g)}),b=!0),n},v=function(){return _(E,x)},_=function(e,n){return n?t(document.getElementById(n)):t(e).first()},y=function(e,t,n){c=n;var r=m();if(c&&d.one("touchend.ojContextMenu",function(e){r.__contextMenuPressHoldJustEnded(!0),setTimeout(function(){r.__contextMenuPressHoldJustEnded(!1)},50)}),"touchstart"===f&&"contextmenu"===e.type||"contextmenu"===f&&"touchstart"===e.type)return f=null,void clearTimeout(l);if(!e.isDefaultPrevented()){var i={launcher:d,initialFocus:"menu",position:{mouse:{my:"start top",at:"start bottom",of:e},touch:{my:"start>40 center",at:"start bottom",of:e,collision:"flipfit"},keyboard:{my:"start top",at:"start bottom",of:"launcher"}}[t]};r.__openingContextMenu=!0,r.open(e,i),r.__openingContextMenu=!1,r.widget().is(":visible")&&(e.preventDefault(),document.addEventListener("keyup",g),"touchstart"!==e.type&&"contextmenu"!==e.type||(f=e.type,l=setTimeout(function(){f=null},300)))}};d.off(".ojContextMenu").removeClass("oj-menu-context-menu-launcher")[0].removeEventListener("click",h,!0),clearTimeout(u);var C=d.data("_ojLastContextMenu");C&&_(C.selector,C.id).off(".ojContextMenu");var b=!1,E=n.utils.unwrapObservable(i()),x=t.isPlainObject(E)?r.getAttribute("contextmenu"):null;d.data("_ojLastContextMenu",{selector:E,id:x}),r.addEventListener("click",h,!0),d.on("touchstart.ojContextMenu mousedown.ojContextMenu keydown.ojContextMenu ",function(e){if("mousedown"!==e.type||!m().__contextMenuPressHoldJustEnded())return c=!1,"touchstart"===e.type&&(p=!0,u=setTimeout(y.bind(void 0,e,"touch",!0),750)),!0}).on("touchend.ojContextMenu touchcancel.ojContextMenu",function(e){return p=!1,clearTimeout(u),!0}).on("keydown.ojContextMenu contextmenu.ojContextMenu",function(e){if("contextmenu"===e.type||121==e.which&&e.shiftKey){var t=p?"touch":"keydown"===e.type?"keyboard":"mouse";y(e,t,!1)}return!0}).addClass(e.DomUtils.isTouchSupported()?"oj-menu-context-menu-launcher":"")}},e.ComponentBinding.getDefaultInstance().setupManagedAttributes({attributes:["header","cell"],init:function(e,t,n,r,i,o,a){var s,u,l,d,f,h,g,m,v;return"header"===e?(null!=(s=t.row)&&null!=(u=s.template)&&(s.renderer=c(a,u)),null!=(l=t.column)&&null!=(d=l.template)&&(l.renderer=c(a,d)),null!=(h=t.rowEnd)&&null!=(g=h.template)&&(h.renderer=c(a,g)),null!=(m=t.columnEnd)&&null!=(v=m.template)&&(m.renderer=c(a,v)),{header:t}):"cell"===e?(null!=(f=t.template)&&(t.renderer=p(a,f)),{cell:t}):void 0},update:function(e,t,n,r,i,o,a){var s,u,l,d,f,h,g,m,v;return"header"===e?(null!=(s=t.row)&&null!=(u=s.template)&&(s.renderer=c(a,u)),null!=(l=t.column)&&null!=(d=l.template)&&(l.renderer=c(a,d)),null!=(h=t.rowEnd)&&null!=(g=h.template)&&(h.renderer=c(a,g)),null!=(m=t.columnEnd)&&null!=(v=m.template)&&(m.renderer=c(a,v)),{header:t}):"cell"===e?(null!=(f=t.template)&&(t.renderer=p(a,f)),{cell:t}):null},for:"ojDataGrid"}),e.ComponentBinding.getDefaultInstance().setupManagedAttributes({attributes:["template"],init:function(e,t,n,r,i,o,a){return h(e,t,a)},update:function(e,t,n,r,i,o,a){return h(e,t,a)},for:"ojDiagram"}),function(){e.__ExpressionUtils={},e.__ExpressionUtils.getPropertyWriterExpression=function(e){if(null==e||["true","false","null","undefined"].indexOf(e)>=0)return null;var n=(e=e.trim()).match(t);return null===n?null:"function(v){"+(n[1]?"Object("+n[1]+")"+n[2]:e)+"=v;}"};var t=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i}(),e.__KO_CUSTOM_BINDING_PROVIDER_INSTANCE.addPostprocessor({getBindingAccessors:function(t,r,i,o){if(null==i)return null;var a=function(t){for(var n=Object.keys(t),r=-0;r0;){var h=e.childNodes[0];u.insertBefore(h,e),f.push(h)}else if("_ojBindForEach_"===t){for(;e.childNodes.length>0;){h=e.childNodes[0];if(u.insertBefore(h,e),f.push(h),1===h.nodeType&&"template"===h.nodeName.toLowerCase()){if(c._templateNode)throw new Error("Multiple templates found: oj-bind-for-each requires a single template element as its direct child");Object.defineProperty(c,"_templateNode",{value:h,enumerable:!1})}}if(!c._templateNode)throw new Error("Template not found: oj-bind-for-each requires a single template element as its direct child")}return u.insertBefore(p,e),f.push(p),u.replaceChild(d,e),f.push(d),f}function i(t,n){if(null!=t){var r=e.__AttributeUtils.getExpressionInfo(t).expr;return null==r&&(r=n?"'"+t+"'":t),r}return null}function o(t,r,i,o,a){var s,u,l,d=e.__AttributeUtils.getExpressionInfo(o).expr;if(null==d)u=e.__AttributeUtils.coerceValue(i,"class",o,"any"),l=Array.isArray(u),s=function(){return l?u.join(" "):u};else{var c=(s=e.ComponentBinding.__CreateEvaluator(d).bind(null,a))();"function"==typeof c?(u=c(),(l=Array.isArray(u))&&(s=n.pureComputed(function(){return c().join(" ")}))):u=c}"string"==typeof u||l?r.class=s:t.css=s}function a(t,n,r,i,o){var a=e.__AttributeUtils.getExpressionInfo(r).expr;return null==a?function(){return"object"===o?e.__AttributeUtils.coerceValue(t,n,r,o):r}:e.ComponentBinding.__CreateEvaluator(a).bind(null,i)}function s(e){return function(){for(var t={},n=Object.keys(e),r=0;r